import os
import common.ReadFile as rf
import convert.ConvertFile as cf

current_path = os.getcwd()
end = (len("convert") + 1) * (-1)
train_directory = current_path[0:end] + '/data/HWDB1.1trn_gnt'
test_directory = current_path[0:end] + '/data/HWDB1.1tst_gnt'
tail = ".gnt"
# root_train = current_path[0:end] + '/data/tf_train_data'
# root_test = current_path[0:end] + '/data/tf_test_data'
root_train = current_path[0:end] + '/data/tf_train_data_part'
root_test = current_path[0:end] + '/data/tf_test_data_part'
part_char_set = '的一是了我不人在他有这个上们来到时大地为子中你说生国年着就那和要她出也得' \
                '里后自以会家可下而过天去能对小多然于心学么之都好看起发当没成只如事把还用' \
                '第样道想作种开美总从无情己面最女但现前些所同日手又行意动方期它头经长儿回' \
                '位分爱老因很给名法间斯知世什两次使身者被高已亲其进此话常与活正感'
# part_char_set = "all"
new_size = 64
head_length = 10

root = [root_train, root_test]
directory = [train_directory, test_directory]

for i in range(len(root)):
    read_file = rf.ReadFile(directory[i], tail)
    read_file.run()
    convert_file = cf.ConvertFile(root[i], read_file.full_path,
                                  head_length, new_size)
    convert_file.run(part_char_set)
    del read_file
